package com.林子祺.全名健康管理系统.dao.content.communicate;

import java.sql.*;

public class AddComm {

    public static void add(String user, String ask, String askPerson) {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/content?useUnicode=true&characterEncoding=utf-8", "root", "blink102417");

            String sql = "insert into ask values(null," + "'" + user + "','" + ask + "','" + askPerson + "',null,null)";

            stmt = conn.createStatement();

            stmt.execute(sql);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
        }
    }
}
